<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //1.unshift动态向数组头部添加一个元素，返回值是新增之后的长度
        const arr = [2, 3, 5]
        //console.log( arr.unshift(3));//返回一个数组长度
        //console.log(arr);//在头部增加
        Array.prototype.myUnshift = function (fn) {

           for(let i=0;i<this.length+1;i++){

            // const re=this[0]
            // console.log(re);
             this[0]=fn
           console.log(this[i]);
           }
            return this.length
        }
        console.log(arr.myUnshift(8));
        console.log(arr);

     
    </script>
</body>

</html>